<?php

/**
 * Helper class that securely executes scripts present in ./bin/
 */
class vtnsBin
{
    private static function passthru($command, $args)
    {
        if (!is_array($args)) {
            $args = array($args);
        }
        
        $commandLine = self::pathToBin().'/'.$command
            .' '.implode(' ', array_map('escapeshellarg', $args));
        
        vtnsLog::info('Running command "%s".', $commandLine);
        
        passthru($commandLine);
    }
    
    public static function pathToBin() {
        return dirname(dirname(dirname(__FILE__))).'/bin';
    }
    
    public static function zip($fileName)
    {
        self::passthru('util/zip', array($fileName));
    }
}

?>
